import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

// 颜色
const kPrimaryColor = Color(0xFFFC0303);
const kTextColor = Color(0xFF101010);
const kLineColor = Color(0x9CBBBBBB);
const kBackgroundColor = Color(0xFFF0F0F0);

/// 主题
ThemeData buildThemeData(BuildContext context) {
  final theme = Theme.of(context);
  return theme.copyWith(
    scaffoldBackgroundColor: kBackgroundColor,
    textTheme: theme.textTheme.copyWith(
      subtitle1: theme.textTheme.subtitle1.copyWith(fontSize: 14.sp),
      bodyText2: theme.textTheme.bodyText2.copyWith(fontSize: 14.sp),
      button: theme.textTheme.button.copyWith(fontSize: 14.sp),
    ),
    navigationRailTheme: theme.navigationRailTheme.copyWith(),
    appBarTheme: theme.appBarTheme.copyWith(
      brightness: Brightness.light,
      actionsIconTheme: IconThemeData(color: kTextColor),
      color: Colors.white,
      elevation: 0,
      iconTheme: IconThemeData(color: kTextColor),
      textTheme: TextTheme(headline6: TextStyle(color: kTextColor, fontSize: 18.sp)),
      centerTitle: true,
    ),
    inputDecorationTheme: theme.inputDecorationTheme.copyWith(
      isDense: true,
      contentPadding: EdgeInsets.symmetric(vertical: 8.w, horizontal: 8.w),
      filled: true,
      fillColor: Colors.white,
      errorBorder: OutlineInputBorder(borderSide: BorderSide(color: kLineColor)),
      focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: kLineColor)),
      focusedErrorBorder: OutlineInputBorder(borderSide: BorderSide(color: kLineColor)),
      disabledBorder: OutlineInputBorder(borderSide: BorderSide(color: kLineColor)),
      enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: kLineColor)),
      border: OutlineInputBorder(borderSide: BorderSide(color: kLineColor)),
    ),
    buttonTheme: theme.buttonTheme.copyWith(
      textTheme: ButtonTextTheme.primary,
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      shape: StadiumBorder(),
      buttonColor: theme.primaryColor,
    ),
    bottomNavigationBarTheme: theme.bottomNavigationBarTheme.copyWith(
      backgroundColor: Colors.white,
      elevation: 0,
      type: BottomNavigationBarType.fixed,
      selectedLabelStyle: TextStyle(fontSize: 11.sp),
      unselectedLabelStyle: TextStyle(fontSize: 11.sp),
    ),
  );
}

ThemeData darkTheme() {
  var themeData = ThemeData(
    brightness: Brightness.dark,
    primarySwatch: Colors.red,
    primaryColor: Color(0xFFD61034),
    scaffoldBackgroundColor: Color(0xFFD61034),
    visualDensity: VisualDensity.adaptivePlatformDensity,
  );
  return themeData.copyWith(
    buttonTheme: themeData.buttonTheme.copyWith(height: 46),
    inputDecorationTheme: themeData.inputDecorationTheme.copyWith(border: InputBorder.none),
    appBarTheme: themeData.appBarTheme.copyWith(color: Colors.transparent, elevation: 0),
  );
}
